package com.huawei;
import java.util.*;
/**
 * Created by Z-hong on 2024/7/22.
 */

public class HJ52 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String a=sc.nextLine();
        String b=sc.nextLine();
        int [][] res=new int[a.length()+1][b.length()+1];
        char[] a_arr = a.toCharArray();
        char[] b_arr = b.toCharArray();
        for (int i = 0; i < res.length; i++) {
            res[i][0]=i;
        }
        for (int i = 0; i < res[0].length; i++) {
            res[0][i]=i;
        }
        //双循环
        for (int i = 1; i < res.length; i++) {
            for (int j = 1; j < res[0].length; j++) {
                if(a_arr[i-1]==b_arr[j-1]){
                    res[i][j]=res[i-1][j-1];
                }else{
                    int del=res[i][j-1]+1;
                    int cha=res[i-1][j-1]+1;
                    int add=res[i-1][j]+1;
                    res[i][j]=Math.min(del,Math.min(cha,add));
                }
            }
        }

        System.out.println(res[a.length()][b.length()]);
    }
}
